﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enterprise.Framework.Frame.Architecture;
using Resto.CostControl.Core.Domain.Model;
using Enterprise.Framework.Core.Exceptions;
using Enterprise.Framework.DomainModel.Repositories;

namespace Resto.CostControl.Core.Domain.Query.DishDeliveryModule
{
    internal class DishDeliveryDQO : IDomainQueryObject
    {
        public DishDelivery GetDishDelivery(string id)
        {
            DishDelivery order = GetDishDeliveryOrDefault(id);

            if (order == null)
                throw new BusinessException("指定Id的菜肴发货单不存在");

            return order;
        }

        public DishDelivery GetDishDeliveryOrDefault(string id)
        {
            IEntityRepository<DishDelivery> repository = RestoCostDomainSession.CurrentSession.CreateEntityRepository<DishDelivery>();
            DishDelivery order = repository.Objects.Where(p => p.ID == id).FirstOrDefault();

            return order;
        }



    }
}
